package fr.jgraph.model.edge;

import fr.jgraph.model.vertex.Vertex;

public abstract class EdgeFactory {
	private EdgeDefinition edgeDef;
	
	public EdgeFactory(EdgeDefinition def) {
	edgeDef = def;	
	}
	
	public Edge createEdge(Vertex[] vertices, Object content) {
		Edge edge = initEdge(vertices,content);
		
		if(edgeDef.isMarkable())
			edge = new MarkableEdge(edge);
		
		if(edgeDef.isWeighted())
			edge = new LongWeightedEdge(edge);
		
		return edge;
	}
	
	protected abstract Edge initEdge(Vertex[] vertices, Object content);
}
